package role

import (
	"context"
	"fmt"

	"go-admin/base/internal/svc"
	"go-admin/base/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeletesLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeletesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletesLogic {
	return &DeletesLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeletesLogic) Deletes(req *types.RoleDeleteReqDTO) (resp *types.RoleBooleanRespDTOS, err error) {
	err = l.svcCtx.RoleModel.DeleteByRoleIds(l.ctx, req.RoleIds)
	if err != nil {
		_ = fmt.Errorf(err.Error())
		return nil, err
	}

	return &types.RoleBooleanRespDTOS{
		Data: true,
		Result: types.Result{
			Code: 200,
		},
	}, nil
}
